Page({
  data: {
    amount: 0,
    ways: [
      {
        id: '1',
        color: 'green',
        icon: 'icon-weixin green',
        label: '微信支付',
        link: '',
        checked: true,
      },
      {
        id: '2',
        color: 'blue',
        icon: 'icon-icon_alipay blue',
        label: '支付宝支付',
        link: '',
        checked: false,
      },
    ]
  },
  onLoad () {
    const self = this
    wx.getStorage({
      key: 'totalAmount',
      success: function(res) {
        if(res.data){
          self.setData({
            amount:res.data
          })
        }
      } 
    })
  },
  checkPayWay (e) {
    const self = this
    let data = e.currentTarget.dataset.obj
    self.data.ways.forEach((item, index)=> {
      var select = 'ways['+index+'].checked'
      if(item.id === data.id){
        self.setData({
          [select]: true
        })
      }else{
        self.setData({
          [select]: false
        })
      }
    })
  }
})